package com.wzs.service.impl;

import com.wzs.dao.IUserDao;
import com.wzs.model.User;
import com.wzs.model.UserCondition;
import com.wzs.service.IUserService;
import com.wzs.util.PageModel;

import java.util.ArrayList;

/**
 * @author miaomiao
 * @version 1.0.0
 * @ClassName UserService.java
 * @Description TODO
 * @createTime 2021-06-19- 14:57:00
 */
public class UserService implements IUserService {

    private IUserDao userDao;

    public IUserDao getUserDao() {
        return userDao;
    }

    public void setUserDao(IUserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public ArrayList<User> getUserListByCondition(UserCondition condition) {
        return userDao.getUserByCondition(condition);
    }

    @Override
    public User getUserDetails(String uId) {
        return userDao.getUserDetails(uId);
    }

    @Override
    public PageModel<User> getUserPageByCondition(UserCondition condition, PageModel<User> pageModel) {
        return userDao.getUserPageByCondition(condition, pageModel);
    }

    @Override
    public boolean deleteUserById(String uId) {
        return userDao.deleteUserById(uId);
    }

    @Override
    public boolean saveOrUpdateUser(User user) {

        if (user.getId() != null) {
            return userDao.updateUser(user);
        }
        return userDao.saveUser(user);
    }


}
